<?php
declare(strict_types=1);

namespace app\controller\index;


use app\result\FeedbackResult;
use app\result\PushResult;
use app\result\UserResult;
use think\App;
use think\facade\Request;

class User extends BaseIndex
{
    protected $unauthorized = ['reg', 'login', 'code_login', 'pwd_login', 'logout','forget_pwd'];

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->objResult = new UserResult();
    }

    public function login()
    {
        data_exit_json($this->objResult->pwd_login($this->param));
    }


    public function info()
    {
        $res = $this->objResult->get_info_by_code($this->user_code);
        data_exit_json($res);
    }


    //注册
    public function reg()
    {
        $data = Request::post();
        data_exit_json($this->objResult->register($data));
    }

    //退出登录
    public function logout()
    {
        data_exit_json($this->objResult->logout($this->token));
    }

    //留言反馈
    public function feedback()
    {
        data_exit_json((new FeedbackResult())->feedback($this->user_id, $this->param));
    }

    //反馈记录
    public function feedback_list()
    {
        data_exit_json((new FeedbackResult())->feedback_list($this->user_id, $this->param));
    }

    //微信小程序登录
    public function code_login()
    {
        data_exit_json($this->objResult->wx_login($this->param));
    }

    //更新信息
    public function update()
    {
        data_exit_json($this->objResult->update_info($this->user_id, $this->param));
    }

    //更新登录账号
    public function update_account()
    {
        data_exit_json($this->objResult->update_account($this->user_id, $this->param));
    }

    //注销
    public function account_cancel()
    {
        data_exit_json($this->objResult->account_cancel($this->user_id, $this->param));
    }

    //注销-撤回
    public function regret_cancel()
    {
        data_exit_json($this->objResult->regret_cancel($this->user_id, $this->param));
    }

    public function update_password()
    {
        data_exit_json($this->objResult->update_password($this->user_id, $this->param));
    }

    //推送设置
    public function push_setting()
    {
        data_exit_json((new PushResult())->push_setting($this->user_id, $this->param));
    }

    //更新邮箱
    public function update_email()
    {
        data_exit_json($this->objResult->update_email($this->user_id, $this->param));
    }

    //关联账号列表
    public function account_list()
    {
        data_exit_json($this->objResult->account_list($this->user_id, $this->param));
    }

    //关联账号
    public function account_bind()
    {
        data_exit_json($this->objResult->account_bind($this->user_id, $this->param));
    }

    //切换账号
    public function account_switch()
    {
        data_exit_json($this->objResult->account_switch($this->user_id, $this->param, $this->token));
    }

    //解除关联
    public function account_unbind()
    {
        data_exit_json($this->objResult->account_unbind($this->user_id, $this->param));
    }

    //忘记密码
    public function forget_pwd()
    {
        data_exit_json($this->objResult->forget_password($this->param));
    }



}


